function RedirectToBook(){
    window.location="/book.html";
}

function redirectToOrderlist()
{
    window.location="/orderlist.html";
}

function returnToMap()
{
    window.location="/index.html";
}

angular.module('OrderlistApp', [])
    .controller('orderlist', function($scope,$http) {
        console.log("get orderlist...");
        var userid=localStorage.getItem("userId");
        $http.get("/orderserver/ordersbyuser?UserId="+userid).then(function(response){
            $scope.orders=response.data;
        });
        $scope.pay=function(x){
            console.log("待支付："+x.strOrderId);
        $http.post("/orderserver/paybyorderid?orderId="+x.strOrderId).then(function(response){
            alert("订单："+x.strOrderId+" 已支付!");
            x.status='已支付';
        });
        }
    })
;

angular.module('bookApp', [])
    .controller('newOrder', function($scope,$http) {
        $scope.isneworder=localStorage.getItem("isneworder");
        $scope.orderId=localStorage.getItem("orderId");
        $scope.orderTime=localStorage.getItem("orderTime");
        $scope.storeId=localStorage.getItem("storeId");
        $scope.storeName=localStorage.getItem("storeName");
        $scope.carID=localStorage.getItem("carID");
        $scope.carFullName=localStorage.getItem("carFactory")+localStorage.getItem("carName");
        $scope.userId=localStorage.getItem("userId");
        $scope.userName=localStorage.getItem("userName");
        $scope.book= function() {
            $http.post("/orderserver/addorder?orderId="+$scope.orderId+"&orderTime="+$scope.orderTime+"&storeId="+$scope.storeId+"&carID="+$scope.carID+"&userId="+$scope.userId+"&orderStatus=未支付").then(function(response){
                console.log(response.data);
                alert('预订成功！');
            });
        }
    })
;

angular.module('myApp', [])
    .controller('carstore', function($scope,$http) {
        $http.get("allstores").then(function(response){
            $scope.names=response.data;
        });
    })
    .controller('orderinfo', function($scope,$http) {
        $http.get("allorders").then(function(response){
            $scope.names=response.data;
        });
    })
;
